#include <iostream>
#include <thread>
#include <future>
using namespace std;

void calculate_square(promise<int> &&p, int x)
{
    p.set_value(x * x);
};

int main()
{
    promise<int> p;
    future<int> f = p.get_future();
    thread t(calculate_square, move(p), 5);
    cout << "Square:" << f.get() << endl;

    t.join();
    return 0;
}